home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / graphics / wheel.zip / wheel.pl < prev    next >
Text File  |  1994-04-20  |  2KB  |  80 lines

  1. # Perl script for a POV-Ray animation, requires wheel.pov
  2. # by Jussi Kantola
  3.  
  4. #
  5. # 1st let's define some macros...
  6. #
  7. $Pi = 3.14592654;
  8. $P2 = $Pi/4;
  9. $P3 = $Pi/2;
  10. $P4 = (3*$Pi)/4;
  11.  
  12. #
  13. # loop to create the required values
  14. #
  15.  
  16. for ($t = 0; $t <= 60; $t++)
  17.    {
  18.    $Sphere1_Rad = sin(($Pi-(($Pi/180)*$t*3)));     # Sphere radiuses
  19.    $Sphere2_Rad = sin(($Pi-(($Pi/180)*$t*3))+$P2); # they fluctuate
  20.    $Sphere3_Rad = sin(($Pi-(($Pi/180)*$t*3))+$P3); # in different 
  21.    $Sphere4_Rad = sin(($Pi-(($Pi/180)*$t*3))+$P4); # phases!
  22.  
  23.    $TRad = sqrt(sin($Pi-($Pi/180)*$t*3)*sin($Pi-($Pi/180)*$t*3));
  24.    $WheelRot = 12*$t;
  25.  
  26.    $L1X = 3*sin(((2*$Pi)-(($Pi/360)*$t*12)));  # spotlights
  27.    $L1Z = 3*cos(((2*$Pi)-(($Pi/360)*$t*12)));
  28.    $L2X = 2*sin(((2*$Pi)+(($Pi/360)*$t*12)));
  29.    $L2Z = 2*cos(((2*$Pi)+(($Pi/360)*$t*12)));
  30.  
  31.    open (MOVIE, ">wheel$t.pov");
  32.       print (MOVIE "#declare Sphere1_Rad = $Sphere1_Rad\n");
  33.       print (MOVIE "#declare Sphere2_Rad = $Sphere2_Rad\n");
  34.       print (MOVIE "#declare Sphere3_Rad = $Sphere3_Rad\n");
  35.       print (MOVIE "#declare Sphere4_Rad = $Sphere4_Rad\n");
  36.       print (MOVIE "#declare TRad = 5*$TRad\n");
  37.       print (MOVIE "#declare WheelRot = $WheelRot\n");
  38.       print (MOVIE "#declare L1X = $L1X\n");
  39.       print (MOVIE "#declare L1Z = $L1Z\n");
  40.       print (MOVIE "#declare L2X = $L2X\n");
  41.       print (MOVIE "#declare L2Z = $L2Z\n");
  42.    close (MOVIE);
  43.    }
  44.  
  45. # now we create a shell script to do the dirty job
  46. # This one creates a MPEG animation using Andy Hung's software
  47. #
  48.  
  49. open (ANIMATE, ">animate");
  50. for ($t = 0; $t <= 60; $t++)
  51.    {
  52.    print (ANIMATE "# wheel$t.pov:\n");
  53.    print (ANIMATE "cat wheel.pov >> wheel$t.pov\n");
  54.    print (ANIMATE "ftpov -iwheel$t.pov -owheel$t.tga wheel.def\n");
  55.    print (ANIMATE "cjpeg -quality 90 -restart 1 wheel$t.tga > wheel$t.jpg\n");
  56.    print (ANIMATE "tgatoppm wheel$t.tga | ppmtoyuvsplit wheel$t\n");
  57.    print (ANIMATE "rm wheel$t.tga\n");
  58.    }
  59. print (ANIMATE "mpeg -a 0 -b 60 -h 160 -v 120 -PF wheel -s wheel.mpg\n");
  60. close (ANIMATE);
  61. chmod 755, "animate";
  62.  
  63. # run this to remove all the unnecessary files after you've created
  64. # the animation...
  65. #
  66.  
  67. open (CLEAN, ">clean");
  68.   print (CLEAN "rm wheel[0-9]*.jpg\n");
  69.   print (CLEAN "rm wheel[0-9]*.pov\n");
  70.   print (CLEAN "rm wheel*.[Y,U,V]\n");
  71. close (CLEAN);
  72. chmod 755, "clean";
  73.  
  74. # a defaults file for pov-ray
  75. #
  76.  
  77. open (DEFS, ">wheel.def");
  78.    print (DEFS "+a0.4 +b32 -c -d +ft +mb1 -p +q9 +v +w160 +h120 -x\n");
  79. close (DEFS);
  80.